﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace System.Linq.Expressions
{
	public static class CompilerExtensions
	{

		public static object CompileAndGetValue( this Expression exp )
		{
			switch ( exp.NodeType )
			{
				case ExpressionType.Constant:
					return ( ( ConstantExpression )exp ).Value;
				default:
					var get = Expression.Lambda<Func<Object>>( Expression.Convert( exp, typeof( object ) ) ).Compile();
					return get();
			}
		}
	}
}
